using System.Collections;

namespace Slaks.DocumentSerialization.Document
{
	public class TermDocumentFrequencyElement
	{
		private long m_termId;
		private Document2DummyMap m_document2DummyMap;

		public TermDocumentFrequencyElement(long termId)
		{
			m_termId = termId;
			m_document2DummyMap = new Document2DummyMap();
		}

		/// <summary>
		/// Add the document name in which this term was found
		/// </summary>
		/// <param name="documentName"></param>
		/// <returns></returns>
		public bool AddDocument(string documentName)
		{
			if (m_document2DummyMap.Contains(documentName)) return false;
			m_document2DummyMap.Add(documentName, DUMMY);
			return true;
		}

		/// <summary>
		/// Get the collection of the documents in which term id was found
		/// </summary>
		/// <returns>collection of document as strings</returns>
		public ICollection GetDocumentCollection()
		{
			return m_document2DummyMap.Keys;
		}

		public bool IsDocumentExists(string documentName)
		{
			return m_document2DummyMap.Contains(documentName);
		}

		public long GetTermId()
		{
			return m_termId;
		}

		public long GetFrequency()
		{
			return m_document2DummyMap.Count;
		}

		private static readonly object DUMMY = new object();
	}
}